home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 015a / seemem20.zip / SEEMEM.DOC next >
Text File  |  1991-12-17  |  12KB  |  216 lines

  1.  
  2.  
  3.  
  4.  
  5.                                 SEEMEM.EXE
  6.  
  7.  
  8.           Author:             Tedrick A. Housh, Jr.
  9.                               5811 West 85th Terrace
  10.                               Overland Park, KS 66207
  11.  
  12.  
  13.           Electronic Mail:    CompuServe 72466,212
  14.                               GEnie      R.HOUSH
  15.  
  16.  
  17.      The objective of SEEMEM is to display information about the
  18.      current use of MS-DOS memory by the operating system, and
  19.      resident processes and data.
  20.  
  21.      It is designed to make full use of the new memory facilities
  22.      provided by DOS version 5.0, and to provide information similar
  23.      to that provided by the DOS utility MEM.  However, it provides
  24.      this information even when DOS does not control Upper or Extended
  25.      memory, and even when HIMEM.SYS and EMM386.EXE are not loaded,
  26.      and recognizes UMB's created by other programs, such as
  27.      Quarterdeck Software's QEMM386 (for 386 and higher) and QRAM (for
  28.      286 cpu's with EMS version 4.00 hardware or Chips and
  29.      Technologies Shadow Ram).  It works with these programs on all
  30.      versions of DOS greater than 1, and on all CPU chips, 8088 and
  31.      higher, although the memory detail displayed increases with
  32.      increase in CPU version.  As of SeeMem version 2.00, it provides
  33.      full support for DR-DOS 6.00 also.
  34.  
  35.      SEEMEM was written in Turbo Pascal 6.00, as an exercise in the
  36.      use of the Built-In Assembler (BASM).  In that connection, all
  37.      necessary DOS functions were specifically coded in BASM, as were
  38.      all functions which necessarily interface with the extended
  39.      memory (XMS) driver provided by HIMEM.SYS, or its counterparts
  40.      such as QEMM386.SYS, or QEXT.SYS, or EMM386.SYS or QEXT.SYS.
  41.      This completely eliminates the need for the Turbo Pascal DOS
  42.      unit, or a unit to interface with the XMS and UMB device drivers.
  43.      All the low level functions necessary for this purpose are
  44.      included directly in the SEEMEM.PAS file as BASM code, and the
  45.      .PAS file is independent and completely self-supporting.
  46.  
  47.      The display output for SEEMEM is in three parts.  The first part,
  48.      which may include several screen pages, displays every memory
  49.      control block (MCB) between Segment 0 and the top of conventional
  50.      memory (Segment 9FFFh on a 640k machine), and also between the
  51.      top of conventional memory and the start of the High Memory Area
  52.      (HMA) if any, or the top of Upper Memory (Segment 0FFFFh).  For
  53.      each MCB SEEMEM displays its segment address (in hex), its size
  54.      (in both Kilobytes and bytes), the segment of its "owner," its
  55.      type (e.g. Process or Environment), and its name (if
  56.      determinable).
  57.  
  58.      The second part is a display of EMS (Expanded Memory) if
  59.      applicable.  This displays the version number of the EMS device
  60.      driver, the page frame segment, the total size of the installed
  61.      EMS memory, the number of mapping register sets available,
  62.      whether or not nonvolatile handles (will survive warm boot) are
  63.      available, the number of DMA channels , the maximum number of EMS
  64.      handles supported, the number of free handles, free pages, page
  65.      size, and free memory, and for each handle in use, the handle
  66.      number, the number of EMS pages, the page size, the memory used,
  67.      and if available, the handle name.  This second part may occupy
  68.      more than one screen page.
  69.  
  70.      The third part displays XMS information (if a driver is
  71.      installed), including XMS version number, revision number, the
  72.      XMM Control Vector in segment:offset form, total XMS free memory,
  73.      and largest free XMS block.  With respect to the High Memory Area
  74.      (HMA) SEEMEM shows whether the A20 line is currently enabled,
  75.      whether HMA is implemented, whether the HMA is available for use.
  76.      If the DOS version is 5.00 or greater SEEMEM also will say
  77.      whether DOS is resident in the HMA (DOS=HIGH in config.sys), and,
  78.      if so, how much of the HMA DOS has left available for additional
  79.      buffers, etc.  SEEMEM also displays the location of DOS when it
  80.      is located elsewhere (i.e. ROM or Conventional memory).
  81.  
  82.      The third part also displays information about Upper Memory
  83.      Blocks (UMB's) if available:  whether UMB's are implemented,
  84.      whether they are controlled by device driver or by DOS itself
  85.      (with DOS 5.00 and higher), whether UMB's are linked to
  86.      conventional memory (DOS 5.00) or are independent, and whether
  87.      UMB's are implemented by DOS=UMB in CONFIG.SYS (DOS 5.00).
  88.  
  89.      Seemem does NOT display device driver information loaded under
  90.      DOS version 4.xx or higher's "secondary" MCB's, although it will
  91.      display such primary MCB's other software may use to load such
  92.      device driver's "high" in UMB's if each is given its own MCB.
  93.      This was a design decision to avoid "clutter."  Plenty of
  94.      programs are available to "walk" the device chain and display
  95.      this information.
  96.  
  97.      A word about resident code names is in order. Under DOS 2.xx the
  98.      name of resident code is not determinable.  With DOS 3.xx the
  99.      name may be determined from the environment, unless that was
  100.      released back to DOS's pool on installation.  With DOS 4.xx and
  101.      higher an eight character name is inserted in the last eight
  102.      bytes of the 16 byte MCB, and therefore is always available.
  103.      Some other programs which control UMB's insert the eight
  104.      character name in the MCB under any DOS version, but this is not
  105.      used by SEEMEM.  SEEMEM uses the most detailed information
  106.      available.  Therefore, if the DOS version is 4 or higher, and the
  107.      environment pertaining to the process is still resident, the
  108.      program name and extension is taken from the environment
  109.      (although the drive and directory information is stripped from
  110.      the filename before display).
  111.  
  112.      A full explanation of the XMS and UMB, and HMA standards is not
  113.      within the scope of this documentation, however an understanding
  114.  
  115.      of a few of the more obscure facts will help understand SEEMEM's
  116.      operation.   The "XMS Specification" for extended memory is
  117.      similar to the EMS spec for expanded memory.  It provides
  118.      functions for implementing use of extended memory with handles in
  119.      a manner very much the same as EMS does for expanded memory.  The
  120.      High Memory Area (HMA) is the 64 kilobyte (less 16 bytes) just
  121.      above the 1 megabyte limit of the 8086 and 8088 chips.
  122.      Obviously, then XMS extended memory and the HMA require a '286
  123.      chip or higher.  However, through a clever addressing scheme, and
  124.      an additional hardware address line, an 80286 or higher can
  125.      address the HMA in "real" mode, i.e. as "non-extended" memory.
  126.      Although XMS drivers existed before DOS 5.00, and some alternative
  127.      DOS-like operating systems allowed the use of this space for some
  128.      things, DOS 5.00 now allows DOS itself to be loaded there,
  129.      substantially increasing the possible useable memory space in
  130.      lower memory previously used by DOS.
  131.  
  132.      Although the protocols and specifications for Upper Memory Blocks
  133.      (UMB's) are contained in the original XMS specifications, they
  134.      are NOT necessarily part of the XMS driver itself, and in fact
  135.      were not implemented by the first MicroSoft driver, HIMEM.SYS.
  136.      The XMS specification only provides one control vector however,
  137.      so if all UMB calls need be implemented through that vector, a
  138.      UMB driver must be integrated with the XMS driver, or must hook
  139.      that vector (necessarily implying that it must be loaded after
  140.      the XMS driver has installed the vector) unless it is completely
  141.      integrated.  However DOS 5.00 has supplied interrupt 21h function
  142.      calls to manipulate the use of existing UMB's for detecting the
  143.      existence, state and governing the rules of use of UMB's, and
  144.      these function calls are not dependent on the existence of any
  145.      device driver, nor for that matter, the existence of any extended
  146.      memory, or a chip higher than that 8088-8086.  The thought may
  147.      take some getting used to, but this means that UMB's can exist
  148.      without any driver or control vector at all.  In fact there is at
  149.      least one program available which acts as though it were a device
  150.      driver, creates UMB's from Chips and Technologies shadow ram,
  151.      hands it over to DOS, and then just aborts, itself disappearing
  152.      from memory.  DOS then owns, and makes available, some UMB's with
  153.      no device driver to control them.  SEEMEM can even detect this
  154.      type of UMB and display its state.
  155.  
  156.      DOS 5.00 provides greatly increased support for XMS, HMA, and
  157.      UMB's, and SEEMEM uses all of it, where it is possible to do so.
  158.  
  159.      In order that it may support full display redirection SEEMEM does
  160.      not do any direct video memory-mapped display.  All display is
  161.      through DOS or BIOS.  Each screen is paged with a "MORE" line at
  162.      the bottom UNLESS the /N ("NO PAUSE") switch is used.  The only
  163.      other switch available is the help /H or /? switch, which
  164.      displays a simple help message.  The output may be directed to a
  165.      file or a device such as a printer, in which case you will
  166.      probably wish to bypass paging also, with the /n switch.  As of
  167.      SeeMem version 2.00 SeeMem detects this redirection and turns
  168.      paging off by itself.
  169.  
  170.      For example SEEMEM /N > PRN  would send the output of the program
  171.      to the printer for a permanent record.  In order to speed the
  172.      output slightly the DOS IOCTL function is used to switch to "raw"
  173.  
  174.      output mode, and is returned to its prior state, probably
  175.      "cooked" upon program termination.  This speeds up output by
  176.      eliminating checks for ^S, ^Q, ^C and expansion of tabs, etc., so
  177.      you cannot manually pause the program or "break" it.  No tabs or
  178.      other characters requiring interpretation are used however, so
  179.      you should see no difference due to disallowance of "cooked"
  180.      mode.
  181.  
  182.      If you insist on a "scrollable" output I have successfully used
  183.      the J.P. Software's 4DOS command shell internal LIST command with
  184.      SEEMEM to provide this with the following command line:
  185.  
  186.        SEEMEM /N | LIST /S
  187.  
  188.      This provides an output which uses LIST to scroll from top to
  189.      bottom.
  190.  
  191.      I have made the source code available in Turbo Pascal 6.0 on the
  192.      Borland Support area on GEnie and in the Borland Programming A
  193.      area in CompuServe as SEMTP2.ZIP.  The program is copyright but
  194.      donated to the public domain without any restriction, except
  195.      that it be distributed in its original form with appropriate
  196.      authorship credit, with no charge other than reasonable fees for
  197.      duplication and distribution, including by electronic means.  It
  198.      is specifically intended and permission is granted for
  199.      distribution by commercial electronic sources for their regular
  200.      and customary access and membership fees even though they may be
  201.      operated for profit.
  202.  
  203.      The basic idea for SEEMEM is not new, of course and all
  204.      parts of it borrow heavily upon prior, similar programs.  Perhaps
  205.      it should be named YAMEM (Yet Another MEMory display program).
  206.      Nevertheless it does do some things no other does (that I know
  207.      of) and it is a demonstration of Turbo Pascal 6's BASM facility
  208.      which clearly shows the practicality of the TP environment for
  209.      low level system programming.  In fact, I don't think the same
  210.      thing could be done in C with faster or smaller code resulting.
  211.      Yeah, I know, TP is primarily a shell for the assembly stuff, but
  212.      at least it can do that now, and very adroitly, too.
  213.  
  214.                           Rick Housh
  215.  
  216.